<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>{$current['title']}-{$Think.CONFIG.sitename}</title>

    <link href="__PUBLIC__/static/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="__PUBLIC__/static/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="__PUBLIC__/static/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="__PUBLIC__/static/css/animate.min.css" rel="stylesheet">
    <include file="Public/commoncss" />
    <!-- Sweet Alert -->
    <link href="__PUBLIC__/static/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
</head>

<body class="gray-bg top-navigation">
<div id="wrapper">
    <div id="page-wrapper" class="gray-bg">
        <div class="row border-bottom white-bg">
            <include file="Public/header" />
        </div>
        <div class="wrapper wrapper-content">
            <div class="row">
                <div class="col-sm-3">
                    <div class="ibox float-e-margins">
                        <include file="Public/deptnav" />
                    </div>
                </div>
                <div class="col-sm-9 animated fadeInRight">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h4>{$current['title']}
                                <div class="ibox-tools">
                                    <a href="javascript:;" style="color:blue;" onclick="window.location.href='{:U('add')}'">
                                        <i class="fa fa-plus"></i>添加部门
                                    </a>
                                </div>
                            </h4>
                        </div>
                        <div class="ibox-content">

                            <table data-toggle="table">
                                <thead>
                                <tr>
                                    <th>部门名称</th>
                                    <th>成员列表</th>
                                    <th>成立日期</th>
                                    <th>部门类型</th>
                                    <th> 操 作 </th>
                                </tr>
                                </thead>
                                <tbody>
                                <if condition="!empty($department)">
                                    <php>
                                        function showTree($data,$pre=null) {

                                        foreach ($data as $key => $val) {
                                        echo '<tr>';
                                        echo '<td>';
                                            if($pre){
                                            echo $pre.'┗━'.$val['name'];
                                            }else{
                                            echo $val['name'];
                                            }
                                            echo '</td>';
                                        echo '<td>';
                                            echo '<a class="green" href="'.U('Member/index',array('dept'=>$val['id'])).'" title="查看成员">查看成员</a>';
                                            echo '</td>';
                                        echo '<td>';
                                            echo beenTime($val['time']);
                                            echo '</td>';
                                        echo '<td>';
                                            echo getDeptType($val['pid']);
                                            echo '</td>';
                                        echo '<td>';
                                            echo '<a class="green" href="'.U('add',array('pid'=>$val['id'])).'" title="新增分类"><i class="ace-icon fa fa-plus-circle bigger-100"></i>新增</a>&nbsp;&nbsp;';
                                            echo '<a class="blue" href="'.U('edit',array('id'=>$val['id'])).'" title="编辑分类"><i class="ace-icon fa fa-pencil-square-o bigger-100"></i>编辑</a>&nbsp;&nbsp;';
                                            echo '<a class="red del" href="javascript:void(0);" val="'.$val['id'].'" title="删除分类"><i class="ace-icon fa fa-trash bigger-100"></i>删除</a>';
                                            echo '</td>';
                                        if (!empty($val['children'])) {
                                        showTree($val['children'],$pre.'&nbsp;&nbsp;');
                                        }

                                        echo '</tr>';
                                        }
                                        }
                                        showTree($department);
                                    </php>
                                    <else />
                                    <tr>
                                        <td colspan="5">暂无部门</td>
                                    </tr>
                                </if>
                                </tbody>

                                </tbody>
                            </table>


                        </div>
                    </div>

                </div>
            </div>
        </div>
        <!--删除提示模态框-->
        <div class="modal inmodal fade" id="delModal" tabindex="-1" role="dialog"  aria-hidden="true">
            <div class="modal-dialog modal-sm">
                <form action="{:U('del')}" role="form" id="delForm">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                            <h4 class="modal-title">友情提示</h4>
                        </div>
                        <div class="modal-body">
                            <p id="delTips">确定删除这些用户组吗？</p>
                        </div>
                        <div class="modal-footer">
                            <input type="hidden" name="ids" id="del-ids" value="">
                            <button type="button" class="btn btn-white" data-dismiss="modal">让我想想</button>
                            <button type="submit" class="btn btn-danger btn-sm"> 是的！ </button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <!--状态提示模态框-->

        <include file="Public/footer" />
    </div>
</div>
<include file="Public/commonjs" />
<script src="__PUBLIC__/static/js/bootstrap.min.js?v=3.3.5"></script>
<script src="__PUBLIC__/static/js/content.min.js?v=1.0.0"></script>
<script src="__PUBLIC__/static/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script src="__PUBLIC__/static/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
<script src="__PUBLIC__/static/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script src="__PUBLIC__/static/js/plugins/validate/Validform_v5.3.2.js"></script>
<script src="__PUBLIC__/static/js/plugins/sweetalert/sweetalert.min.js"></script>

<script type="text/javascript">
    $(function() {
        $('.del').click(function () {
            var delid= $(this).attr("val");
            swal({
                title:"您确定删除这个部门吗",
                text: "删除后将不可以恢复！",
                type: "info",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                cancelButtonText:"取消",
                confirmButtonText: "确定",
                closeOnConfirm: false
            }, function () {
                $.post("{:U('del')}",{id:delid},function(data){
                    if(data.status !== 'y'){
                        swal('操作失败!',data.info, "warning");
                    }else{
                        window.location.reload();
                    }
                });
            });
        });
    });
</script>
</body>

</html>